    
jQuery.noConflict();
   
   
String.prototype.endsWith = function(str) {
   return (this.match(str+"$")==str)}
   

var inSearch = false;

function searchTextChanged() {
    setTimeout("handleSearch()", 10);
}

function handleSearch() {
    if (inSearch) {
       setTimeout("handleSearch()", 500);
       return;
   }
    var text = document.search_form.search_text.value;
    var last_ch = text.substring(text.length-1);
    // only invoke search on non-alpha character
    if ( " .,!?\n".indexOf(last_ch) >= 0 ) {
        inSearch = true;
        doSearch(text);
        inSearch = false;
    }
}

function doSearch(text) {
    var params = {"description": text};
    var url = "/services/search_by_description/";
    
    jQuery.post(url, params,
      function(data, textStatus){
        update_graph(data);
      }, "json");
    
}
 
function update_graph(data, textStatus) {
    clear_graph();
    load_graph(data);
}
 
 
function load_person_details(nickname) {
    var url = "/services/person/" + nickname + "/";
    
    jQuery.post(url, null,
      function(data, textStatus){
        view_person(data);
      }, "json");
}                      
 
function view_person(data) {
    YAHOO.example.Basic = new function() {
        var myColumnDefs = [
            {key:"content", sortable:true, resizeable:true},
            {key:"update_time", sortable:true, resizeable:true},                   
        ];

        this.myDataSource = new YAHOO.util.DataSource(data);
        this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_JSARRAY;
        this.myDataSource.responseSchema = {
            fields: ["content","update_time"]
        };

        this.myDataTable = new YAHOO.widget.DataTable("basic",
                myColumnDefs, this.myDataSource);
    };
}
